package com.example.lotterysystem.common.exception;

import com.example.lotterysystem.common.errorcode.ErrorCode;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * Created with IntelliJ IDEA.
 * Description: controller 层自定义异常
 * User: Li_Xiaochi
 * Date: 2025/8/1
 * Time: 16:19
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class ControllerException extends RuntimeException{
    /**
     * 异常码
     * @see com.example.lotterysystem.common.errorcode.ControllerErrorCodeConstants
     */
    private Integer code;

    /**
     * 异常消息
     */
    private String msg;

    // TODO ???
    // 为了序列化，所以加了无参构造函数
    public ControllerException() {

    }

    public ControllerException(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public ControllerException(ErrorCode errorCode) {
        this.code = errorCode.getCode();
        this.msg = errorCode.getMsg();
    }
}
